//
//  HHButton.m
//  YSJ
//
//  Created by 花花 on 2016/12/16.
//  Copyright © 2016年 花花. All rights reserved.
//

#import "HHButton.h"

@implementation HHButton
-(instancetype)initWithFrame:(CGRect)frame{


    if (self = [super initWithFrame:frame]) {
      
        
        [self commonInit];
      
      
      
    }
    return self;
}


-(void)layoutSubviews{
    
    
    [super layoutSubviews];
    
    
    self.imageView.width = self.width * 0.4;
    self.imageView.x = (self.width - self.imageView.width) /2;
    self.imageView.height = self.imageView.width;
    
    self.imageView.y = self.height * 0.15;
    
    self.titleLabel.x = 0;
    self.titleLabel.y = self.imageView.bottom;
    self.titleLabel.width = self.width;
    self.titleLabel.height = self.height - self.imageView.height;
    
    
    
    
    
}


-(void)commonInit{
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
//    [self sizeToFit];
    self.imageView.contentMode = UIViewContentModeScaleAspectFit;
    self.titleLabel.font = [UIFont systemFontOfSize:12];
}

//- (CGRect)titleRectForContentRect:(CGRect)contentRect{
//    CGFloat titleX = 0;
//    CGFloat titleY = contentRect.size.height * 0.65;
//    CGFloat titleW = contentRect.size.width;
//    CGFloat titleH = contentRect.size.height - titleY;
//    return CGRectMake(titleX, titleY, titleW, titleH);
//}
//
//- (CGRect)imageRectForContentRect:(CGRect)contentRect{
//    CGFloat imageW = CGRectGetWidth(contentRect);
//    CGFloat imageH = contentRect.size.height * 0.4;
//    return CGRectMake(0, 5, imageW, imageH);
//}

@end
